<?php
/**
 * Created by PhpStorm.
 * User: liuhong
 * Date: 2019-04-09
 * Time: 16:54
 */

namespace app\service;


use app\common\model\Course;
use app\common\model\UserTourist;
use think\Db;
use think\Exception;

use GuzzleHttp\Client;

/**
 * Class CoachService
 * @package app\service
 */
class TouristService extends BaseService
{
    public $touristModel;

    public function __construct()
    {
        $this->touristModel = new UserTourist();
    }

    /**
     * @param $where
     * @param $page
     * @param $size
     * @param string $filed
     * @param string $order
     * @return array|bool
     */
    public function queryPage($where, $page, $size, $filed = '*', $order = 'id desc')
    {
        try {
            $info = $this->touristModel
                ->where($where)
                ->order($order)
                ->page($page, $size)
                ->select()
                ->toArray();
            foreach ($info as $key => $value) {

            }
            return $info;
        } catch (Exception $ex) {
            LogService::S()->writeLog('Exception', $ex->getMessage());
            return false;
        }
    }

    /**
     * 编辑
     * @param $save
     * @param array $where
     * @return bool|false|int|string
     */
    public function querySave($save, $where = [])
    {
        try {
            if ($where) {
                $res = $this->touristModel->save($save, $where);
            } else {
                $res = $this->touristModel->insertGetId($save);
            }
            return $res;
        } catch (Exception $ex) {
            LogService::S()->writeLog('Exception', $ex->getMessage());
            return false;
        }
    }

    /**
     * 查询数量
     * @param $where
     * @return bool|int|string
     */
    public function queryCount($where)
    {
        try {
            return $this->touristModel->where($where)->count();
        } catch (Exception $ex) {
            LogService::S()->writeLog('Exception', $ex->getMessage());
            return false;
        }
    }
}